package sg.edu.nus.iss.vmcs.store;

/*
 * Copyright 2003 ISS.
 * The contents contained in this document may not be reproduced in any
 * form or by any means, without the written permission of ISS, other
 * than for the purpose for which it has been supplied.
 *
 */

/**
 * A class that represent a item to be stored in a Store
 * has a quantity attribute to represent the current quantity
 *
 * @version 3.0 5/07/2003
 * @author Olivo Miotto, Pang Ping Li
 */

public class StoreItem {

	private StoreObject content;
	private int quantity;

	/**
	 * Constructor that creates a StoreItem with a StoreObject and quantity
	 * 
	 * @param content
	 *            content of this StoreItem will represent
	 * @param quantity
	 *            the quantity of this StoreItem
	 */
	public StoreItem(StoreObject content, int quantity) {
		this.content = content;
		this.quantity = quantity;
	}

	/**
	 * Get the Content of this StoreItem
	 * 
	 * @return the StoreObject
	 */
	public StoreObject getContent() {
		return content;
	}


	/**
	 * Set the Content of this StoreItem
	 * 
	 * @param ct
	 *            the new Content
	 */
	public void setContent(StoreObject ct) {
		content = ct;
	}

	/**
	 * Set the quantity of this StoreItem
	 * 
	 * @param quantity
	 *            the new quantity
	 */
	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	/**
	 * Get the quantity of this StoreItem
	 * 
	 * @return the quantity
	 */
	public int getQuantity() {
		return quantity;
	}

	/**
	 * Increment the quantity by one Simulate the storing of a new item
	 */
	public void store() {
		quantity++;
	}
	
	/**
	 * Decrement the quantity by one
	 */
	public void decrement() {
		quantity--;
		if (quantity < 0)
			quantity = 0;
	}

	/**
	 * Increment the quantity by one
	 */
	public void increment() {
		quantity++;
	}
}